﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace spacex.util.Logger
{
    public class PanCamLogger
    {
        private string fileName;
        public static PanCamLogger Instance; 

        /// <summary>
        /// Constructor sets the filename when the logger is first created
        /// </summary>
        private PanCamLogger() 
        {
            DateTime now = DateTime.Now;
            fileName = now.Year + "_" + now.DayOfWeek + "_" + now.Hour + "_" + now.Minute + "_" + now.Second + "_panCamLogfile.txt";
        }

        /// <summary>
        /// Singleton method used to get an instance of the logger
        /// </summary>
        /// <returns></returns>
        public static PanCamLogger GetInstance(){
            if(Instance == null){
                Instance = new PanCamLogger();
                return Instance;
            }
            return Instance;
        }

        /// <summary>
        /// Logs a message to the specified path (usually C:pancam\logger)
        /// </summary>
        /// <param name="messageToLog"></param>
        public void LogMessage(string messageToLog)
        {
            try
            {
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\pancam-user\PanCam\" + @"rec\" + fileName, true))
                {
                    //file.WriteLine(messageToLog);
                }
            }
            catch
            {
                return;
            }
        }
    }
}
